﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PServiceBus.Core.Runtime.Transports;
using PServiceBus.Core.Interface;
using PServiceBus.Core.Runtime.Extensions;

namespace PServiceBus.Core.Runtime.Messages {
    public class ResequenceMessage : IIdentifiable, IDeleteable {
        public ResequenceMessage() : this(TransportMessage.Empty) {
            
        }

        public ResequenceMessage(TransportMessage message) {
            ID = Guid.NewGuid();
            Message = message;
            Init();
        }

        private void Init() {
            if (Message.IsEmpty || Message.Headers == null) return;
            SequenceID = Message.Headers.Get<ulong>(Constants.ESB_SEQUENCE_ID_KEY);
            GroupID = Message.Headers.Get<string>(Constants.ESB_GROUP_ID_KEY);
        }

        public ulong SequenceID { get; set; }
        public string GroupID { get; set; }
        public Guid TopicID { get; set; }
        public Guid SubscriberID { get; set; }
        public TransportMessage Message { get; set; }
        #region IIdentifiable Members
        public Guid ID { get; set; }
        #endregion
    }
}
